<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- 
            js 语法中 基本类型数据的赋值为 值传递
                      引用类型数据的赋值为 地址传递（引用传递）
         -->
        <ul>
            <!-- 
                如果循环时，产生的数据变量为基本数据类型取值，那么循环内部不能直接为该变量赋值，因为不具有响应式
                如果想保留响应式，必须将操作转为引用指向关系
             -->
            <li v-for="(name, i) in names">
                {{ name }} ：
                <!-- <input type="text" v-model="name"> -->
                <input type="text" v-model="names[i]">
            </li>
        </ul>
        <hr>
        <ul>
            <!-- 
                如果循环时，产生的数据变量为引用数据类型取值，那么循环内部可以直接完成该变量的赋值，因为引用数据的操作为地址指向操作
             -->
            <li v-for="(u, i) in users">
                {{ u.name }}
                <input type="text" v-model="users[i].name">
                <input type="text" v-model="u.name">

            </li>
        </ul>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                names:["Esteban","Ken","Gerard","Pascale","Trinity"],
                users:[
                    { name:"Bud",job:"Agent" },
                    { name:"Vladimir",job:"Designer" },
                    { name:"Emery",job:"Planner" },
                    { name:"Milton",job:"Liaison" },
                    { name:"Arnulfo",job:"Architect" },
                    { name:"Dallin",job:"Designer" }
                ]
            }
        })

        let names = ["Esteban","Ken","Gerard","Pascale","Trinity"];
        for (let item of names) {
            item = "aaa"
        }
        let users = [
            { name:"Bud",job:"Agent" },
            { name:"Vladimir",job:"Designer" },
            { name:"Emery",job:"Planner" },
            { name:"Milton",job:"Liaison" },
            { name:"Arnulfo",job:"Architect" },
            { name:"Dallin",job:"Designer" }
        ]
        for (let item of users) {
            // item = "aaa"
            item.name = "aaaa"
        }
    </script>
</body>
</html>